<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>画一个矩形</title>
</head>
<script language="javascript">
    function init() {
        var canvas = document.getElementById("output");
        var context = canvas.getContext("2d");
        //canvas.clientWidth=window.innerWidth;
        //canvas.clientHeight=window.innerHeight;
        context.fillstyle = "rgb(0,255,0)";
        context.fillRect(10, 10, 500, 600);
        //context.fill();
    }
</script>

<body>
    <canvas id="output" onload="init()"></canvas>
</body>

</html>